﻿var ClassArr=_class;////类别数据
////set类别名称
function setClassName(){
    var x = document.getElementById("ctl00$ContentPlaceHolder1$ClassID").value;
    if(x){
        var a = GetClassNameByclassID(x);
        if(a){ClassName(a);}
    }
}
////类别名称
function ClassName(x){
    var classname=document.getElementById("ctl00_ContentPlaceHolder1_ClassName");
    if(x){
        classname.innerHTML="原(" + x + ") <br/>";
    }else{
        return classname.innerHTML;
    }
}

function GetClassNameByclassID(ID){
    var c = "";
    var ClassArray=new Array();
    for(var x in ClassArr){
	   if(x==ID){
	      var _classArray=_class[x];
	      c = _classArray[0];
	      if(_classArray[1]!="0")
	      {
	          c = GetClassNameByclassID(_classArray[1]) + " > " + c;
	      }
	      break;
	   }
    }
    return c;
}


function GetClassByParentID(ParentID){
  var ClassArray=new Array();
  for(var x in _class){
     var _classArray=_class[x]
	 if(_classArray[1]==ParentID){
	    var _array=new Array();
		_array[0]=_classArray[0];
		_array[1]=x;
        _array[2]=_classArray[2];
		ClassArray.push(_array);        
	 }
  } 
  return ClassArray;
}

function Hidden(x){
    var obj = document.getElementById("table"+x);
    if(obj.style.display==""){
        obj.style.display="none";
    }else{
        obj.style.display="";
    }
}
function selectType(){
    var boj = document.getElementsByName("RadioButtonList_ProductType");
    var bojvalue;
    for(i=0;i<boj.length;i++){
        if(boj[i].checked)
            bojvalue = boj[i].value;
    }
    
    if(bojvalue=="1"){
        document.getElementById("display_productType_1").style.display="";
        document.getElementById("display_productType_2").style.display="none";
        document.getElementById("display_productType_3").style.display="none";
    }else if(bojvalue=="2"){
        document.getElementById("display_productType_2").style.display="";
        document.getElementById("display_productType_1").style.display="none";
        document.getElementById("display_productType_3").style.display="none";
    }else if(bojvalue=="3"){
        document.getElementById("display_productType_3").style.display="";
        document.getElementById("display_productType_1").style.display="none";
        document.getElementById("display_productType_2").style.display="none";
    }
}
function selectVideoType(){
    if(document.getElementById("proudct_video_type_0").checked){
        document.getElementById("proudct_video_type_url_div").style.display="";
        document.getElementById("proudct_video_type_upload_div").style.display="none";
    }else if(document.getElementById("proudct_video_type_1").checked){
        document.getElementById("proudct_video_type_url_div").style.display="none";
        document.getElementById("proudct_video_type_upload_div").style.display="";
    }
}
function changeTeam(){
    var obj = document.getElementById("DropTeamNum");
    var objvalue = obj.options[obj.selectedIndex].value;
    for(var i=1;i<=5;i++){
        if(i<=objvalue){
            document.getElementById("team_"+i).style.display="";
        }else{
            document.getElementById("team_"+i).style.display="none";
        }
    }
}
function selectProductPublishTime()
{
    if(document.getElementById("ProductPublishTime_1").checked)
    {
        document.getElementById("PublishStartTr").style.display="";
    }else{
        document.getElementById("PublishStartTr").style.display="none";
    }
}
function CheckSubmit(){
    if(document.getElementById("ProductName").value==""){
        alert("请填写商品名称！");
        document.getElementById("ProductName").focus();
        return false;
    }
    
    var MM_ProductType = document.getElementsByName("RadioButtonList_ProductType");
    var ProductTypevalue;
    for(i=0;i<MM_ProductType.length;i++){
        if(MM_ProductType[i].checked)
            ProductTypevalue = MM_ProductType[i].value;
    }
    if(ProductTypevalue=="1"){
        if(document.getElementById("StandPrice").value==""){
            alert("请填写商品价格！");
            document.getElementById("StandPrice").focus();
            return false;
        }
    }else if(ProductTypevalue=="2"){
        if(document.getElementById("AuctionPrice").value==""){
            alert("请填写商品起拍价！");
            document.getElementById("AuctionPrice").focus();
            return false;
        }
        if(document.getElementById("AuctionAddPrice").value==""){
            alert("请填写商品加价幅度！");
            document.getElementById("AuctionAddPrice").focus();
            return false;
        }
    }else if(ProductTypevalue=="3"){
        if(document.getElementById("OriginallyPrice").value==""){
            alert("请填写商品原始价！");
            document.getElementById("OriginallyPrice").focus();
            return false;
        }
    }
    return true;
}



function SelectClass()
{
    var html;
    var classArray = GetClassByParentID(0);
    html = "<select size='10' onchange=\"return slectchild(this.value,this.options[this.selectedIndex].text,0)\">";
    for(var i=0;i<classArray.length;i++)
    { 
        var _name=classArray[i][0];
        if(classArray[i][2]!="0")
        {
            _name = _name + " > ";
        }
        html += "<option value="+classArray[i][1]+">"+_name+"</option>";
    }
    html += "</select>";
    
    var ObjDIV = document.getElementById("ClassBar");
    ObjDIV.style.display="";
    ObjDIV.style.position="absolute";
    document.getElementById("ClassBarContent").innerHTML = html;
}

function slectchild(id,text,barid)
{
   
    var html;
    var classArray = GetClassByParentID(id);
    var boj = document.all("hlClassBarItem");

    if(boj=="[object]"){
        var length = 0;
        if(boj.length==undefined){
            length = 1;
        }else{
            length = boj.length;
        }
        for(var j = barid; j < length; j++){
            if(length==1)
            {
                document.getElementById("ClassBarContent").removeChild(boj);
            }else{
                document.getElementById("ClassBarContent").removeChild(boj[barid]);
            }
        }
    }
    var classnameobj = document.all("hlclassname")
    if(classnameobj=="[object]")
    {
   
        var length = 0;
        if(classnameobj.length==undefined){
            length = 1;
        }else{
            length = classnameobj.length;
        }
        for(var j = barid; j < length; j++){
            if(length==1)
            {
                 
                document.getElementById("ctl00_ContentPlaceHolder1_ClassName").removeChild(classnameobj);
            }else{
                 
                document.getElementById("ctl00_ContentPlaceHolder1_ClassName").removeChild(classnameobj[barid]);
            }
        }
    }
    
     
    document.getElementById("ctl00_ContentPlaceHolder1_ClassName").innerHTML += "<span id='hlclassname'>"+text+"</span>";
    document.getElementById("ctl00$ContentPlaceHolder1$ClassID").value = id;
    if(classArray.length==0){return;}
    
    html = "<span id='hlClassBarItem'><select size='10' onchange=\"return slectchild(this.value,this.options[this.selectedIndex].text,"+ barid + 1 +")\">";
    for(var i=0;i<classArray.length;i++)
    {
        var _name=classArray[i][0];
        if(classArray[i][2]!="0")
        {
            _name+=" > ";
        }
        html += "<option value="+classArray[i][1]+" onclick='return slectchild("+classArray[i][1]+")'>"+_name+"</option>";
    }
    html += "</select></span>";

    var ObjDIV = document.getElementById("ClassBarContent");
    ObjDIV.innerHTML += html;
}

function previewImg(obj)
{
    var previewImage = document.getElementById("previewImage");
    previewImage.innerHTML = "<img src='" + obj + "' width='100' height='100' borber=0 />"
}